<template>
  <!--  <Login />-->
  <div id="app">
    <transition v-if="token" name='fade' mode='out-in'>
      <HomeView />
    </transition>
    <Login @loginSucceed="loginSucceed" v-else></Login>
  </div>
</template>

<script>
import HomeView from './views/homeView.vue'
import Login from "@/views/login/index.vue";
import {getStore} from "js-utils";
import eventBus from "@/config/eventBus";
export default {
  name: 'App',
  components: { HomeView ,Login},//直接用router-view来根据路由的URL来展示页面
  data () {
    return {
      token:getStore('token',true)
    }
  },
  created() {
    eventBus.$on('clear-token', () => {
      this.token = null;
    });
  },
  beforeDestroy() {
    // 组件销毁时移除监听
    eventBus.$off('clear-token');
  },
  methods:{
    loginSucceed(val){
      this.token = val
    }
  }
}
</script>

<style>
@import "./assets/css/global.scss";
html,body,#app{
  margin: 0;
  height: 100%;
}
.el-breadcrumb{
  margin-bottom: 15px;
  font-size: 12px;
}
.el-table{
  margin-top: 15px;
}
.el-pagination{
  margin-top: 15px;
}
</style>
No newline at end of file
<template>
  <!--  <Login />-->
  <div id="app">
    <transition v-if="token" name='fade' mode='out-in'>
      <HomeView />
    </transition>
    <Login @loginSucceed="loginSucceed" v-else></Login>
  </div>
</template>

<script>
import HomeView from './views/homeView.vue'
import Login from "@/views/login/index.vue";
import {getStore} from "js-utils";
export default {
  name: 'App',
  components: { HomeView ,Login},//直接用router-view来根据路由的URL来展示页面
  data () {
    return {
      token:getStore('token',true)
    }
  },
  methods:{
    loginSucceed(val){
      this.token = val
    }
  }
}
</script>

<style>
@import "./assets/css/global.scss";
html,body,#app{
  margin: 0;
  height: 100%;
}
.el-breadcrumb{
  margin-bottom: 15px;
  font-size: 12px;
}
.el-table{
  margin-top: 15px;
}
.el-pagination{
  margin-top: 15px;
}
</style>
No newline at end of file
